﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebTemplate.DAL.Entities;
using WebTemplate.DAL.Repositories;

namespace WebTemplate.Web
{
    public partial class AnyStaticPage : System.Web.UI.Page
    {
        private int? Id
        {
            get
            {
                var Id = this.Request.QueryString["Id"];
                if (string.IsNullOrWhiteSpace(Id))
                    return null;
                return int.Parse(Id);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Id.HasValue)
                {
                    StaticRepository repository = new StaticRepository();
                    var Static = repository.Select(new StaticSearchCriteria() { Id = this.Id.Value }).First();

                    this.txtDescription.Text = Static.Content;
                }
            }

        }
    }
}